using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Backend.JYD.Model.Cust;

namespace Backend.JYD.EFDAL.Mapping
{
    public class CustContactMap : EntityTypeConfiguration<CustContact>
    {
        public CustContactMap()
        {
            // Primary Key
            this.HasKey(t => t.CustNo);

            // Properties
            this.Property(t => t.CustNo)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.EMail)
                .HasMaxLength(50);

            this.Property(t => t.Msn)
                .HasMaxLength(50);

            this.Property(t => t.QQ)
                .HasMaxLength(20);

            this.Property(t => t.WebSite)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("CustContact");
            this.Property(t => t.CustNo).HasColumnName("CustNo");
            this.Property(t => t.EMail).HasColumnName("EMail");
            this.Property(t => t.Msn).HasColumnName("Msn");
            this.Property(t => t.QQ).HasColumnName("QQ");
            this.Property(t => t.WebSite).HasColumnName("WebSite");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.CreateTime).HasColumnName("CreateTime");
            this.Property(t => t.UpdateTime).HasColumnName("UpdateTime");
            this.Property(t => t.OpId).HasColumnName("OpId");

            // Relationships
            this.HasRequired(t => t.CustBaseInfo)
                .WithOptional(t => t.CustContact);
        }
    }
}
